<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>Example A: Loading/saving/export of XML</TITLE>
    <META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <META name="GENERATOR" content="Doc-O-Matic">
    <LINK rel="STYLESHEET" href="default.css" type="text/css">

<SCRIPT LANGUAGE="JavaScript1.2" SRC="scripts.js"></SCRIPT>
</HEAD>
<BODY CLASS="body">
<TABLE BORDER="0" BGCOLOR="#AACCFF" WIDTH="100%" CELLSPACING="0" CELLPADDING="0">
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">
<DIV CLASS="pageheadertitle">
NativeXml Help</DIV>
</TD><TD VALIGN="MIDDLE" ALIGN="LEFT">
<DIV CLASS="pageheaderlinks">
<A HREF="content.html" CLASS="link">Content</A> | <A HREF="idx.html" CLASS="link">Index</A> | <A HREF="symref.html" CLASS="link">Reference</A></DIV>
</TD></TR></TABLE><DIV CLASS="topictitle">
Example A: Loading/saving/export of XML</DIV>
<DIV CLASS="topiclinklist">
<A HREF="000000.html" CLASS="link">Examples of NativeXml usage</A></DIV>
<DIV CLASS="topictextblock">
<DIV CLASS="topictext">
This example shows how to load an XML document and then export it in readable format to a TMemo field.<P CLASS="topictext">
 Drop a TEdit (Edit1), TButton (Button1) and a TMemo on your form, then connect the code below to the OnClick event of the button. Fill in the filename in Edit1, then click the button and you will see the contents of the XML file listed in the memo control.<P CLASS="topictext">
<DIV CLASS="codeblock">
<DIV CLASS="code">
<PRE CLASS="code">
procedure TForm1.Button1Click(Sender: TObject);
var
  ADoc: <A HREF="000155.html" CLASS="link">TNativeXml</A>;
begin
  Memo1.Lines.Clear;
  ADoc := <A HREF="000170.html" CLASS="link">TNativeXml.Create</A>;
  try
    ADoc.LoadFromFile(Edit1.Text);
    ADoc.XmlFormat := xfReadable;
    Memo1.Lines.Text := ADoc.WriteToString;
  finally
    ADoc.Free;
  end;
end;
</PRE></DIV>
</DIV>
Note that <I>ADoc.XmlFormat := xfReadable</I> will make sure that the document is listed in readable form (with carriage returns and indents).</DIV>
</DIV>

</BODY></HTML>